package dk.com.test;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import dk.com.entities.PersonEntities;

public class PersonTableModel extends AbstractTableModel{
	private static final long serialVersionUID = -5550035813562395661L;
		private List<PersonEntities> li = new ArrayList<PersonEntities>();
	    private String[] columnNames = { "ADA", "Name"};

	    public PersonTableModel(List<PersonEntities> list){
	         this.li = list;
	    }

	    @Override
	    public String getColumnName(int columnIndex){
	         return columnNames[columnIndex];
	    }

	    @Override     
	    public int getRowCount() {
	        return li.size();
	    }

	    @Override        
	    public int getColumnCount() {
	        return columnNames.length; 
	    }

	    @Override
	    public Object getValueAt(int rowIndex, int columnIndex) {
	    	PersonEntities si = li.get(rowIndex);
	        switch (columnIndex) {
	            case 0: 
	                return si.getId();
	            case 1:
	                return si.getFirstName();
	           }
	           return null;
	   }

	   @Override
	   public Class<?> getColumnClass(int columnIndex){
	          switch (columnIndex){
	             case 0:
	               return String.class;
	             case 1:
	               return Integer.class;
	             case 2:
	               return String.class;
	             case 3:
	               return Double.class;
	             case 4:
	               return Double.class;
	             case 5:
	               return String.class;
	             case 6:
	               return Boolean.class;
	             }
	             return null;
	      }
	 }